package com.gxxy.spring.kp03_aop.cls02_aop.s01_xml;

import org.aspectj.lang.ProceedingJoinPoint;

// AOP: Aspect Oriented Programming
// aspectj: Aspect Java
// Execution表达式: 过滤method

public class TransactionManager {

	/**
	 * 事务的开启
	 */
	public void begin() {
		System.out.println("TransactionManager.begin()");
	}

	/**
	 * 事务的提交
	 */
	public void commit() {
		System.out.println("TransactionManager.commit()");
	}

	/**
	 * 事务的回滚
	 */
	public void rollback(Throwable e) {
		System.out.println("TransactionManager.rollback()");
		System.out.println("e: "+ e.getMessage());
	}

	/**
	 * 执行完毕
	 */
	public void finished() {
		System.out.println("TransactionManager.finished()");
	}
	
	
	public void all(ProceedingJoinPoint point) {
			try {
				begin();
				point.proceed();
				commit();
			} catch (Throwable e) {
				rollback(e);
			} finally {
				finished();
			}
	}

}
